//
//  JiuDianSecondCell.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/21.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "JiuDianSecondCell.h"
#import "UILabel+HWDUILabel.h"
#import "chooseBtnView.h"
#import "HotelBTnView.h"
@implementation JiuDianSecondCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)loadCell:(NSDictionary *)dataDic
{
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    //酒店的名字
    _hotelName = [UILabel new];
    _hotelName.textColor = TextBlack;
    _hotelName.font = [UIFont systemFontOfSize:17*screenW_6];
    _hotelName.text = dataDic[@"name"];
    _hotelName.numberOfLines = 0;
    [self.contentView  addSubview:_hotelName];
    [_hotelName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView ).offset(10*screenW_6);
        make.top.equalTo(self.contentView.mas_top).offset(15*screenW_6);
        make.width.equalTo(@(SCREENW-190*screenW_6));
    }];

    
      //星星
    _startView = [UIView new];
    [self.contentView addSubview:_startView];
    [_startView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10*screenW_6);
        make.top.equalTo(_hotelName.mas_bottom).offset(10*screenW_6);
        make.width.equalTo(@(SCREENW-190*screenW_6));
        make.height.equalTo(@(20*screenW_6));
    }];
    [self addStart:dataDic];
    
    //价格
    _moneyLab = [UILabel new];
    _moneyLab.textColor = TextRed;
    _moneyLab.font = [UIFont systemFontOfSize:13*screenW_6];
    _moneyLab.text = [NSString stringWithFormat:@"¥%@起 %@人已消费",dataDic[@"consumeMoney"],dataDic[@"consumeNumber"]];
    [self.contentView  addSubview:_moneyLab];
    [_moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView ).offset(10*screenW_6);
        make.top.equalTo(_startView.mas_bottom).offset(10*screenW_6);
        make.width.equalTo(@(SCREENW-190*screenW_6));
        make.height.equalTo(@(20*screenW_6));
    }];
    [_moneyLab setTextFont:[NSString stringWithFormat:@"%@人已消费",dataDic[@"consumeNumber"]] font:[UIFont systemFontOfSize:12*screenW_6]];
    [_moneyLab setHighlightStirng:[NSString stringWithFormat:@"%@人已消费",dataDic[@"consumeNumber"]] HighlightColor:TextGray];
    
    //画线
    _lineLab = [UILabel new];
    _lineLab.backgroundColor = LineColor;
    _lineLab.text = @" ";
    [self.contentView  addSubview:_lineLab];
    [_lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.height.equalTo(@1);
        make.top.equalTo(_moneyLab.mas_bottom).offset(15*screenW_6);
        make.bottom.equalTo(self.contentView).offset(0);
    }];
    
    //添加按钮
    [self addBtn];
    
}

//循环创建星星
-(void)addStart:(NSDictionary *)startDic
{
    for (UIImageView *subImageV in _startView.subviews) {
        [subImageV removeFromSuperview];
    }
    
    for (int i = 0; i < 5; i++) {
        float x =20*screenW_6*i;
        UIImageView *startImageV = [TomamaUI createImageView:CGRectMake(x,0,15*screenW_6,15*screenW_6) backGroundImageV:@"Mian_star_hui"];
        //        if ([ToolViewVC isNotNullStr:startDic[@"evaluateLevel"]]) {
        if (i< [startDic[@"starClass"] integerValue]) {
            startImageV.image = [UIImage imageNamed:@"Main_star_select"];
        }else
        {
            startImageV.image = [UIImage imageNamed:@"Mian_star_hui"];
        }
        //        }
        startImageV.tag = i+1;
        startImageV.userInteractionEnabled = NO;
        [_startView addSubview:startImageV];
    }
    
}
-(void)addBtn{
    
    NSArray *imageArr = @[@"diqiu_icon",@"dingdan_icon",@"tel_icon",@"zhoubian_icon"];
    NSArray *titleArr = @[@"网址链接",@"添加订单",@"电话预定",@"查看周边"];
    //循环创建按钮
    for (int i = 0; i< 4; i++) {
        float x = (SCREENW-190*screenW_6)+95*screenW_6*(i%2);
        float y = 15*screenW_6 + 35*screenW_6*(i/2);
        HotelBTnView*chooseBtn = [[HotelBTnView alloc]initWithFrame:CGRectMake(x, y, 85*screenW_6,25*screenW_6) Title:titleArr[i] NomolImageV:imageArr[i] SelectImageV:@"" IsSelect:NO];
        [chooseBtn.layer setCornerRadius:5*screenW_6];
        chooseBtn.layer.masksToBounds = YES;
        chooseBtn.layer.borderWidth = 1;
        chooseBtn.layer.borderColor = [LineColor CGColor];
        [self addSubview:chooseBtn];
        chooseBtn.tag = i;
        [chooseBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click:)]];
    }
}

-(void)click:(UITapGestureRecognizer *)tap
{
    if (_block) {
        _block(tap.view.tag);
    }
}



@end
